package com.puzzlebazar.client.hashiwokakero;

import com.puzzlebazar.client.puzzle.model.Move;
import com.puzzlebazar.client.puzzle.model.MoveVisitor;
import com.puzzlebazar.client.puzzle.model.PuzzleModel;
import com.puzzlebazar.client.util.Vec2i;

public class MoveRemoveIsland extends MoveIsland {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1215587876249862000L;

	/**
	 * Only for serialization
	 */
	protected MoveRemoveIsland() {
		super();
	}
	
	/**
	 * Creates a move to remove an island from a model
	 * 
	 * @param loc    Location of the island to remove
	 * @param value  Value of the island to remove
	 */
	public MoveRemoveIsland(Vec2i loc, int value) {
		super(loc, value);
	}

	@Override
	public Move apply(PuzzleModel model) throws Exception {
		return deleteIsland(model);
	}

	@Override
	public Move  unapply(PuzzleModel model) throws Exception {
		return createIsland(model);
	}

	@Override
	public void accept(MoveVisitor visitor) throws Exception {
		if( !(visitor instanceof HashiwokakeroMoveVisitor) ) 
			super.accept(visitor);
		else
			((HashiwokakeroMoveVisitor)visitor).visitRemoveIslandMove(this);
	}	
	
}
